home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / trueSpace 7.6 / tS761B8Std.exe / {app} / Scripts / MaterialEditor / Bricks / Compound / PhongTS.Brick.xml < prev    next >
Extensible Markup Language  |  2008-06-10  |  2KB  |  32 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <ME_BRICK GUID="{4CEA0D51-CE86-4F9D-8301-8AF680F50EC8}" Name="RtTSPhong" GUIName="TS Phong Lighting" Description="The phong lighting model for trueSpace transfer">
  3.     <ME_BRICK_INPUTPARAM GUID="{9278CE24-116C-45E5-9EE2-7CCC6686B983}" Name="DiffuseStrength" Type="RtFloat"/>
  4.     <ME_BRICK_INPUTPARAM GUID="{10BE32CC-1F0F-4BA9-8BF0-F9351D114BA6}" Name="DiffuseColor" Type="RtFloat4"/>
  5.     <ME_BRICK_INPUTPARAM GUID="{66823E43-0404-4883-A429-0A68ABC667CF}" Name="SpecularStrength" Type="RtFloat"/>
  6.     <ME_BRICK_INPUTPARAM GUID="{738AD189-5EFC-4DB7-93BF-0F20F2185C9F}" Name="Shininess" Type="RtFloat"/>
  7.     <ME_BRICK_INPUTPARAM GUID="{9BDA47C6-5953-4E24-914E-3A5D41192446}" Name="NormalVector" Type="RtFloat3"/>
  8.     <ME_BRICK_INPUTPARAM GUID="{4C85B9DD-ADA5-48DE-B50B-A65F2DA95A9D}" Name="EyeVector" Type="RtFloat3"/>
  9.     <ME_BRICK_INPUTPARAM GUID="{C8CCD12B-8898-465F-A92A-A879CCDDA26A}" Name="LightVector" Type="RtFloat3"/>
  10.     <ME_BRICK_INPUTPARAM GUID="{953CD223-1EBB-4508-8D24-E9A0CC856FCA}" Name="LightColor" Type="RtFloat4"/>
  11.     <ME_BRICK_OUTPUTPARAM GUID="{EF5316D8-6022-4518-848E-EC74ECD990CA}" Name="ResultColor" Type="RtFloat4"/>
  12.     <ME_BRICK_CODE><![CDATA[
  13.     //The phong lighting function for TS
  14.     void RtTSPhong(in RtFloat DiffuseStrength, in RtFloat4 DiffuseColor, in RtFloat SpecularStrength, 
  15.                    in RtFloat Shininess, in RtFloat3 NormalVector, in RtFloat3 EyeVector, in RtFloat3 LightVector, 
  16.                    in RtFloat4 LightColor, out RtFloat4 ResultColor)
  17.     {
  18.         ResultColor = RtFloat4(0,0,0,0);
  19.         RtFloat DiffuseCoef = rtx_Dot(NormalVector, LightVector);
  20.         if (DiffuseCoef>0)
  21.         {
  22.             RtFloat3 vLightReflect = rtx_Reflect(rtx_Negate(LightVector), NormalVector);
  23.             RtFloat EyeDotReflect = rtx_Saturate(rtx_Dot(EyeVector, vLightReflect));
  24.             RtFloat SpecularCoef = rtx_Pow(EyeDotReflect, Shininess) * SpecularStrength;
  25.             RtFloat4 DiffuseCol = DiffuseStrength * DiffuseCoef * DiffuseColor;
  26.             ResultColor.rgb = (DiffuseCol + SpecularCoef) * LightColor;
  27.         }
  28.         ResultColor.a = DiffuseColor.a;
  29.     }
  30.     ]]></ME_BRICK_CODE>
  31. </ME_BRICK>
  32.